import { defineStore } from "pinia";
import i18n from "@/locals";


interface IState {
    list: IItem[];
    popSwitch: boolean;
}

interface IItem {
    title: string;
    selected?: boolean;
    value:string;
}

export const useSwitch = defineStore("Switch", {
    state: (): IState => ({
        list:[
            {
                title:"StockSignal",
                selected:true,
                value:"StockSignal"
            },
            // {
            //     title:i18n.global.t("message.CoinState.l"),
            //     selected:false,
            //     value:"signal"
            // },
            {
                // title: "AO(动量震荡指标)",
                title:i18n.global.t("message.CoinState.wg"),
                selected:true,
                value: "WG",
            }
        ],
        popSwitch: false
    }),
    // getters: {
    //     main(state) {
    //         let ary = state.list.filter(i => i.selected);
    //         console.log("主图遮罩物变化", ary)
    //         return ary;
    //     },
      
    // },
    actions: {
        toggleItem(item: IItem) {
            item.selected = !item.selected;
        },
        clearSelected() {
            this.list.forEach(i => (i.selected = false));
        },
        getSwitch() {
            return this.list.filter(i => i.selected);
        },
        changePopSwitch(val: boolean) {
            this.popSwitch = val;
        },
        togglePopSwitch() {
            this.popSwitch = !this.popSwitch;
        }
    }
});
